<?php

class CategoryController extends Zend_Controller_Action
{
	public function init()
	{
		$this->view->headTitle("Category");
	}
	
	public function indexAction()
	{
		// action body
	}
	public function detailAction()
	{
		$id=$this->_getParam("id");
		$dishMapper= new Model_DishMapper();
		$data=$dishMapper->getDishesByCategory($id);
		$this->view->dishes=$data;
		
		$catM=new Model_CategoryMapper();
		$cat=$catM->getCategory($id);
		$this->view->categoryName=$cat->getName();
		$this->view->total=$cat->getTotalDishes();
		$this->view->description=$cat->getDescription();
	}
	
	public function createprocessAction(){
		if ($this->_request->isPost())
		{
			$name=$this->_getParam("cat-name");
			$des=$this->_getParam("cat-description");
			
			$error="";
			 
			$cat=new Model_Category();
			$cat->setName($name)->setDescription($des);
			
			$catM=new Model_CategoryMapper();
			$result= $catM->createCategory($cat);
			

			 
			if ($result=="error")
			{
				
			}
			else
			{
				
			}
			 
			 
		}
		
	}
	
	
}

